package com.acwing.partition34;

import java.io.*;

/**
 * @author rkc
 * @date 2022/8/6 8:51
 */
public class AC3391今年的第几天 {

    private static int[] months = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        while (true) {
            String s = reader.readLine();
            if (s == null || s.isEmpty()) break;
            String[] ss = s.split(" ");
            int y = Integer.parseInt(ss[0]), m = Integer.parseInt(ss[1]), d = Integer.parseInt(ss[2]);
            int ans = d;
            for (int i = 1; i < m; i++) ans += months[i];
            if (m > 2 && ((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0))) ans++;
            writer.write(ans + "\n");
        }
        writer.flush();
    }
}
